home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 29 / CDT29.iso / e-Mail / WorldClient Pro 2.2.3 / wcsetup.exe / WEBHELP.ZIP / hhapplet / IndexSecondaryDialog.class (.txt) < prev    next >
Encoding:
Java Class File  |  1999-10-21  |  4.2 KB  |  164 lines

  1. package hhapplet;
  2.  
  3. import java.applet.Applet;
  4. import java.awt.BorderLayout;
  5. import java.awt.Button;
  6. import java.awt.Color;
  7. import java.awt.Component;
  8. import java.awt.Container;
  9. import java.awt.Dimension;
  10. import java.awt.Event;
  11. import java.awt.Font;
  12. import java.awt.Frame;
  13. import java.awt.Label;
  14. import java.awt.List;
  15. import java.awt.Panel;
  16. import java.awt.Point;
  17. import java.awt.Toolkit;
  18. import java.net.MalformedURLException;
  19. import java.util.Vector;
  20.  
  21. public class IndexSecondaryDialog extends Frame {
  22.    protected Button m_btnDisplay = new Button("Display");
  23.    protected Button m_btnCancel = new Button("Cancel");
  24.    protected List m_list = new List();
  25.    protected Applet m_applet;
  26.    protected Vector m_vEntries;
  27.    protected DialogDoneTarget m_ddtDone;
  28.    private boolean m_bIsIE3 = false;
  29.    private Point m_pntPosition;
  30.  
  31.    public boolean gotFocus(Event var1, Object var2) {
  32.       if (var1.target == this) {
  33.          this.m_list.requestFocus();
  34.          return true;
  35.       } else {
  36.          return super.gotFocus(var1, var2);
  37.       }
  38.    }
  39.  
  40.    public IndexSecondaryDialog(Applet var1, Vector var2, DialogDoneTarget var3) {
  41.       super("Topics Found");
  42.       this.m_applet = var1;
  43.       this.m_vEntries = var2;
  44.       this.m_ddtDone = var3;
  45.       if (System.getProperty("java.vendor").startsWith("Microsoft") && System.getProperty("java.version").startsWith("1.0")) {
  46.          this.m_bIsIE3 = true;
  47.       }
  48.  
  49.       int var4 = WebHelp.GetFontSize();
  50.       this.m_list.setFont(new Font(WebHelp.GetFontName(), 0, var4));
  51.  
  52.       for(int var5 = 0; var5 < this.m_vEntries.size(); ++var5) {
  53.          this.m_list.addItem(((IndexSecondaryEntry)this.m_vEntries.elementAt(var5)).name);
  54.       }
  55.  
  56.       this.m_list.select(0);
  57.       Panel var11 = new Panel();
  58.       ((Container)var11).add(this.m_btnDisplay);
  59.       ((Container)var11).add(this.m_btnCancel);
  60.       ((Container)this).setLayout(new BorderLayout(5, 5));
  61.       this.m_list.setBackground(Color.white);
  62.       ((Component)this).setBackground(new Color(192, 192, 192));
  63.       short var6 = 300;
  64.       short var7 = 240;
  65.       ((Component)this).resize(var6, var7);
  66.       ((Container)this).add("North", new Label("   Click a topic, then click Display."));
  67.       ((Container)this).add("Center", this.m_list);
  68.       ((Container)this).add("South", var11);
  69.       Dimension var8 = Toolkit.getDefaultToolkit().getScreenSize();
  70.       int var9 = var8.width / 2 - var6 / 2;
  71.       int var10 = var8.height / 2 - var7 / 2;
  72.       this.m_pntPosition = new Point(var9, var10);
  73.       ((Component)this).move(var9, var10);
  74.       ((Frame)this).setResizable(false);
  75.    }
  76.  
  77.    public List getList() {
  78.       return this.m_list;
  79.    }
  80.  
  81.    protected void gotoSelectedIndex() {
  82.       int var1 = this.m_list.getSelectedIndex();
  83.       if (var1 != -1) {
  84.          try {
  85.             IndexSecondaryEntry var2 = (IndexSecondaryEntry)this.m_vEntries.elementAt(var1);
  86.             if (var2.frame != null) {
  87.                this.m_applet.getAppletContext().showDocument(URLFileHandler.makeURL(this.m_applet.getDocumentBase(), var2.local, var2.url), var2.frame);
  88.             } else {
  89.                this.m_applet.getAppletContext().showDocument(URLFileHandler.makeURL(this.m_applet.getDocumentBase(), var2.local, var2.url), "_self");
  90.             }
  91.          } catch (MalformedURLException var3) {
  92.          }
  93.  
  94.          this.closeDialog();
  95.          ((Frame)this).dispose();
  96.       }
  97.  
  98.    }
  99.  
  100.    public void show() {
  101.       if (this.m_bIsIE3) {
  102.          Dimension var1 = ((Component)this).size();
  103.          ((Component)this).reshape(this.m_pntPosition.x, this.m_pntPosition.y, var1.width, var1.height);
  104.          super.show();
  105.          ((Component)this).reshape(this.m_pntPosition.x, this.m_pntPosition.y, var1.width, var1.height);
  106.       } else {
  107.          super.show();
  108.       }
  109.  
  110.       this.m_list.requestFocus();
  111.    }
  112.  
  113.    public boolean action(Event var1, Object var2) {
  114.       if (var1.target != this.m_btnDisplay && var1.target != this.m_list) {
  115.          if (var1.target == this.m_btnCancel) {
  116.             this.closeDialog();
  117.             return true;
  118.          } else {
  119.             return false;
  120.          }
  121.       } else {
  122.          this.gotoSelectedIndex();
  123.          return true;
  124.       }
  125.    }
  126.  
  127.    protected void closeDialog() {
  128.       ((Frame)this).dispose();
  129.       if (this.m_ddtDone != null) {
  130.          this.m_ddtDone.dialogDone();
  131.       }
  132.  
  133.    }
  134.  
  135.    public boolean handleEvent(Event var1) {
  136.       if (!System.getProperty("java.version").startsWith("1.1.5") || !System.getProperty("java.vendor").startsWith("Netscape") || var1.id != 401 || var1.key != 10 || var1.target != this.m_btnDisplay && var1.target != this.m_btnCancel) {
  137.          if (var1.id == 201) {
  138.             this.closeDialog();
  139.             ((Frame)this).dispose();
  140.          } else {
  141.             if (var1.target == this.m_list && var1.key == 10 && var1.id == 401) {
  142.                this.gotoSelectedIndex();
  143.                return true;
  144.             }
  145.  
  146.             if (var1.target == this.m_list && var1.key == 10 && var1.id == 402) {
  147.                if (System.getProperty("java.version").equals("1.1") && System.getProperty("java.vendor").startsWith("Microsoft")) {
  148.                   this.gotoSelectedIndex();
  149.                   return true;
  150.                }
  151.             } else if (var1.key == 27 && var1.id == 402) {
  152.                this.closeDialog();
  153.                ((Frame)this).dispose();
  154.             }
  155.          }
  156.  
  157.          return super.handleEvent(var1);
  158.       } else {
  159.          this.action(var1, var1.target);
  160.          return true;
  161.       }
  162.    }
  163. }
  164.